#pragma once

#include "stdafx.h"
#include "util/named.h"

namespace natrium {
	namespace core {
		class Config:
			public util::UniqueNamed,
			public boost::noncopyable
		{
		public:
			Config();
			virtual ~Config();

			bool load(const std::string& filename);
			void parseCommandLine(int argc, char* argv[]);

			bool isAvailable(const std::string& identifier) const;

			boost::program_options::options_description& settings();

			template <typename T>
			T get(const std::string& name) const;

		private:
			boost::program_options::options_description mOptions;
			boost::program_options::variables_map mVariables;
		};

		template <typename T>
		T Config::get(const std::string& name) const {
			if (isAvailable(name))
				return mVariables[name.c_str()].as<T>();
			else
				throw std::runtime_error(std::string("Failed to find variable: " + name));
		}
	}
}